Overview

This document has code embedded throughout. In the next section we will create a visualization using the already loaded dataset cryptodata:

datatable(cryptodata, rownames = FALSE, 
          options(list(lengthMenu = c(4, 5, 6))))

Price Chart

Interactive Chart

Python Code Example

import pandas as pd
# Create the Python object from R
df = r.cryptodata
# Show the new Python dataframe
df
##         pair symbol  ask_1_price       date_time_utc
## 0     ETHUSD    ETH      547.572 2020-12-09 05:00:01
## 1     ETHUSD    ETH      552.120 2020-12-09 04:00:01
## 2     ETHUSD    ETH      549.790 2020-12-09 03:00:01
## 3     ETHUSD    ETH      547.455 2020-12-09 02:00:01
## 4     ETHUSD    ETH      550.456 2020-12-09 01:00:01
## ...      ...    ...          ...                 ...
## 2023  ETHUSD    ETH      347.606 2020-09-09 14:00:38
## 2024  ETHUSD    ETH      346.886 2020-09-09 13:00:39
## 2025  ETHUSD    ETH      347.578 2020-09-09 12:00:39
## 2026  ETHUSD    ETH      346.624 2020-09-09 11:00:38
## 2027  ETHUSD    ETH      357.844                 NaT
## 
## [2028 rows x 4 columns]

One more Python example

Press on w on your keyboard to make the presentation wider. Press f to fullscreen.

import numpy as np
# Create a new field based on the ask_1_price value:
df['price_percentile'] = np.where(df['ask_1_price'] > np.percentile(df['ask_1_price'], 50),
                            'upper 50th percentile of prices', 
                            'lower 50th percentile of prices')
# Show modified dataframe:
df[['symbol', 'ask_1_price', 'price_percentile']]
##      symbol  ask_1_price                 price_percentile
## 0       ETH      547.572  upper 50th percentile of prices
## 1       ETH      552.120  upper 50th percentile of prices
## 2       ETH      549.790  upper 50th percentile of prices
## 3       ETH      547.455  upper 50th percentile of prices
## 4       ETH      550.456  upper 50th percentile of prices
## ...     ...          ...                              ...
## 2023    ETH      347.606  lower 50th percentile of prices
## 2024    ETH      346.886  lower 50th percentile of prices
## 2025    ETH      347.578  lower 50th percentile of prices
## 2026    ETH      346.624  lower 50th percentile of prices
## 2027    ETH      357.844  lower 50th percentile of prices
## 
## [2028 rows x 3 columns]

Back to Gallery